package com.hackerrank.challenges.buildingalist;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Solution {
	private static List<String> getComb(char c[], int i) {
		List<String> l = new ArrayList<String>();
		if(i >= c.length)
			return l;
		l.add(Character.toString(c[i]));
		List<String> sl = getComb(c, i + 1);
		for(String comb : sl)
			l.add(c[i] + comb);
		l.addAll(sl);
		return l;
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int T = in.nextInt();
		for(int t = 0; t < T; t++) {
			int N = in.nextInt();
			in.nextLine();
			char c[] = in.nextLine().toCharArray();
			Arrays.sort(c);
			for(String comb : getComb(c, 0)) {
				System.out.println(comb);
			}
		}
	}
}
